import {
    request
} from '../../../utils/api.js'
import Toast from '@vant/weapp/toast/toast';
Page({
    data: {
        checked: [],
        option1: [{
                text: '全部',
                value: 0
            },
            {
                text: '西安',
                value: 1
            },
            {
                text: '汉中',
                value: 2
            },
            {
                text: '宝鸡',
                value: 3
            },
        ],
        value1: 0,
        type: '',
        user: null,
        student: [],
    },

    onChange(e) {
        console.log(e);
        let index = e.currentTarget.dataset.index
        this.setData({
            [`checked.${[index]}`]: e.detail
        });
    },

    onSearch(e) {
        console.log(e.detail);
    },

    all() {
        for (let index = 0; index < 10; index++) {
            this.setData({
                [`checked.${[index]}`]: true
            })
        }
    },
    cancellation() {
        this.setData({
            checked: []
        })
    },
    next() {
        wx.navigateTo({
            url: '/pages/finances/help/help',
        })
    },
    examine() {
        wx.navigateTo({
            url: '/pages/finances/examine/examine',
        })
    },
    details(e) {
        let userId = e.currentTarget.dataset.index
        wx.navigateTo({
            url: '/pages/student/student?userId=' + userId,
        })
    },
    add() {
        wx.navigateTo({
            url: '/pages/personal/info/info?add=true',
        })
    },
    /**
     * 生命周期函数--监听页面加载
     */
    async onLoad(options) {
        Toast.loading({
            message: '加载中...',
            forbidClick: true,
            duration: 0
        });
        this.setData({
            type: options.type
        })
        const user = wx.getStorageSync('user')
        this.setData({
            user
        })
        console.log(user.schoolId);
        console.log(user.lessonId);
        let res = await request({
            url: `/school/selectStudentByTeacher?schoolId=${user.schoolId}&lessonId=${user.lessonId}`,
            method: 'get',
        })
        console.log(res);
        this.setData({
            student: res.result
        })
        Toast.clear();
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})